from django.db import models

# Create your models here.


class UserModel(models.Model):
    username=models.CharField(max_length=20)
    password=models.CharField(max_length=20)
    price=models.DecimalField(max_digits=6,decimal_places=1,default=0)
    vip=models.BooleanField(default=False)

    class Meta:
        db_table='user'

class TeacherModel(models.Model):
    name=models.CharField(max_length=20)
    nr=models.CharField(max_length=20)

    class Meta:
        db_table='teacher'

class StudyModel(models.Model):
    title=models.CharField(max_length=20)
    prices=models.DecimalField(max_digits=6,decimal_places=1,default=0)
    times=models.CharField(max_length=20)

    class Meta:
        db_table='study'

class TimeModel(models.Model):
    user=models.ForeignKey(UserModel,on_delete=models.CASCADE,null=True,blank=True)
    teacher=models.ForeignKey(TeacherModel,on_delete=models.CASCADE,null=True,blank=True)
    start=models.DateTimeField(auto_now_add=True)
    end=models.DateTimeField(null=True)
    money=models.DecimalField(max_digits=6,decimal_places=1,default=0)
    counts=models.IntegerField(default=0)

    class Meta:
        db_table='time'

class Time2Model(models.Model):
    user = models.ForeignKey(UserModel, on_delete=models.CASCADE, null=True, blank=True)
    study = models.ForeignKey(StudyModel, on_delete=models.CASCADE, null=True, blank=True)
    money=models.IntegerField(default=0)

    class Meta:
        db_table='money'


